package com.cssy.authority.service.impl;

import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.byd.acegiext.domain.User;
import com.cssy.authority.dao.ScDepartmentDAO;
import com.cssy.authority.entity.ScDepartmentDO;
import com.cssy.authority.service.IScDepartmentService;
import com.plat.exception.SyBaseException;
import com.plat.helper.SearchConditions;
import com.plat.helper.SearchResult;
import com.plat.util.IDCodeTypeUtil;


@Service("scDepartmentService")
public class ScDepartmentServiceImpl implements IScDepartmentService{

	
	@Resource(name="scDepartmentDAO")	
	private ScDepartmentDAO scDepartmentDAO;
	
	
	@Override
	public SearchResult findListByExample(SearchConditions scs)
			throws SyBaseException {
		SearchResult rs=new SearchResult(scs);
		List<ScDepartmentDO>  list=scDepartmentDAO.find(scs);
		rs.setRecordCount(scDepartmentDAO.count(scs));
		rs.setResults(list);
		return rs;
	}

	@Override
	public Integer delete(String id, User user) throws SyBaseException {
		ScDepartmentDO basic=new ScDepartmentDO();
		basic.setDutime(new Date());
		basic.setDuuser(user.getName());
		basic.setId(id);
		basic.setRemoved(new Short("1"));
		scDepartmentDAO.updateBasicDepartmentDO(basic);
		return null;
	}

	@Override
	public Integer update(ScDepartmentDO t, User user) throws SyBaseException {
		t.setDuuser(user.getName());
		t.setDutime(new Date());
		return scDepartmentDAO.updateBasicDepartmentDO(t);
	}

	@Override
	public ScDepartmentDO save(ScDepartmentDO t, User user)
			throws SyBaseException {
		t.setDcruser(user.getName());
		t.setDctime(new Date());
		t.setId(IDCodeTypeUtil.getId());
		t.setRemoved(Short.parseShort("0"));
		scDepartmentDAO.insertBasicDepartmentDO(t);
		return t;
	}

	@Override
	public ScDepartmentDO findListById(String id) throws SyBaseException {
		return scDepartmentDAO.findBasicDepartmentDOByPrimaryKey(id);
	}

	@Override
	public List<ScDepartmentDO> getBasicDepartmentDOAll()
			throws SyBaseException {
		SearchConditions scs = new SearchConditions();
		List<ScDepartmentDO>  list = scDepartmentDAO.find(scs);
		return list;
	}

	@Override
	public Integer deleteBizRemoved(String id) throws SyBaseException {
		// TODO Auto-generated method stub
		return null;
	}

}
